/
/ Code Section
/
*0200 / code starts at address 0200
main, cla cll / clear AC and Link
dca Count / clear Count (AC is zero)
dca PosSum / clear PosSum (AC is zero)
dca NegSum / clear NegSum (AC is zero)
tad Addr / get address of array - 1
dca 10 / and store in auto-index register 10
Loop, cla cll / clear AC and Link
tad i 10 / get A[i]
sna / if A[i] = 0
jmp Done / then done
spa / test if A[i] > 0
jmp .+4 / else A[i] < 0
tad PosSum / add to PosSum
dca PosSum / store PosSum
jmp .+3 / jump to increment Count
tad NegSum / add to NegSum
dca NegSum / store NegSum
isz Count / increment Count
jmp Loop / go again
Done, hlt / done
jmp Main / allow easy restart
/
/ Data Section
/
*0100 / global variables stored on page 0
Addr, A-1 / address of array A - 1
*0300 / local variables stored starting at address 0300
Count, 0 / Count of items in array
NegSum, 0 / Sum of negatives
PosSum, 0 / Sum of positives
/
/ Array
/
*0400 / Array starts at address 0400 - Page 2
A, -2; 1; 5; 3; -3; -1; -5; 2; 4; -4; 0
$Main